package com.kdzy.lshy.socity_server.controller;

import com.kdzy.lshy.socity_server.service.GlobleQueryService;
import io.swagger.annotations.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * 一体机 - 全局查询
 * @author cly
 * @since 2018-06-21
 */
@RestController
@RequestMapping("/globleQuery")
@CrossOrigin("*")
@Api(value = "GlobleQueryController", description = "一体机 - 全局查询")
public class GlobleQueryController {

    private static final Logger logger = LoggerFactory.getLogger(GlobleQueryController.class);

    @Resource
    private GlobleQueryService globleQueryService;

    /**
     * 全局查询 -- 根据级别查询
     * @param param
     * @return
     */
    @RequestMapping(value = "/list", method = RequestMethod.POST)
    @ApiOperation(notes = "/list", httpMethod = "POST", value = "全局查询 -- 根据级别查询", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiResponses({
            @ApiResponse(code = 0, message = "成功"),
            @ApiResponse(code = 1, message = "结果集为空"),
            @ApiResponse(code = 88, message = "参数为空"),
            @ApiResponse(code = 77, message = "数据库操作失败"),
            @ApiResponse(code = 98, message = "参数类型错误"),
            @ApiResponse(code = 99, message = "后台处理异常")
    })
    public Object list(
            @ApiParam(
                    required = true,
                    name = "param",
                    value = "{\n" +
                            " \"stamp\": 时间戳,\n" +
                            " \"is_used\": 是否有效 0:有效 1:无效,\n" +
                            " \"version\": 版本 0:测试 1:生产,\n" +
                            " \"visit_plat\": 访问平台 0:网页 1:一体机 2:小程序 3:其他,\n" +
                            " \"visit_type\": 访问类型 0:测试 1:生产,\n" +
                            " \"content\": \"输入框内容\"\n" +
                            "}")
            String param){
        logger.info("进入《全局查询 -- 根据级别查询》list()方法；入参param = " + param);
        return globleQueryService.getAllByCondition(param);
    }

}
